import { SkeletonBinary } from "../spine/runtime/SkeletonBinary3.5.js";
const parse = (data) => {
  const parser = new SkeletonBinary();
  parser.data = data;
  parser.initJson();
  return parser.json;
};
export default function (path) {
  return new Promise((res, rej) => {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", path, true);
    xhr.responseType = "arraybuffer";
    xhr.onloadend = (e) => {
      if (xhr.status >= 200 && xhr.status < 300) {
        res(parse(new Uint8Array(xhr.response)));
      } else {
        rej(xhr.status);
      }
    };
    xhr.send();
  });
}
